export const Type = {
  text: "text",
  imageUrl: "imageUrl",
  switch: "switch",
  radio: "radio",
  select: "select",
  multiSelect: "multiSelect",
  mentions: "mentions",
  stepper: "stepper",
  array: "array",
  upload: 'upload',
};

// createText("名称", "123")
export function createText(label, selectedValue, options) {
  return { type: Type.text, name: label, config: options, extra: { selectedValue } };
}

// createSwitch("开关", true)
export function createSwitch(label, selectedValue, options) {
  return { type: Type.switch, name: label, config: options, extra: { selectedValue } };
}
// createStepper("年龄", 3, {
//   min: 2,
//   max: 6,
// })
export function createStepper(label, selectedValue, options) {
  return { type: Type.stepper, name: label, config: options, extra: { selectedValue } };
}
// createSelect("爱吃的食物", "banana", {
//   placeholder: "Please select...",
//   options: [
//     { label: "苹果", value: "apple" },
//     { label: "香蕉", value: "banana" },
//   ],
// })
export function createSelect(label, selectedValue, options) {
  return { type: Type.select, name: label, config: options, extra: { selectedValue } };
}
// createRadio("国家", "china", [
//   { label: "china", value: "中国" },
//   { label: "japan", value: "日本" },
// ])
export function createRadio(label, selectedValue, options) {
  return { type: Type.radio, name: label, config: options, extra: { selectedValue } };
}
// createMultiSelect("最喜欢的学科", ['computer', 'computer-and-technogy'], {
//   placeholder: "Please select...",
//   options: [
//     {
//       label: "计科系",
//       value: "computer",
//       children: [
//         { label: "软件工程", value: "software" },
//         { label: "计算机科学与技术", value: "computer-and-technogy" },
//       ],
//     },
//     {
//       label: "艺术系",
//       value: "art",
//       children: [
//         { label: "跳舞", value: "dance" },
//         { label: "美术", value: "paint" },
//       ],
//     },
//   ],
// })
export function createMultiSelect(label, selectedValue, options) {
  return { type: Type.multiSelect, name: label, config: options, extra: { selectedValue } };
}

// createArray('Array', [{url: '', open: false}], {
//   url: createText("链接"),
//   open: createSwitch("Open"),
// })
export function createArray(label, selectedValue, config) {
  return { type: Type.array, name: label, config, extra: { selectedValue } };
}

export function createUpload(label, selectedValue, config) {
  return { type: Type.upload, name: label, config, extra: { selectedValue } };
}